package com.simonall.access.dao.impl;

import java.io.Serializable;
import java.math.BigInteger;

import com.simonall.access.dao.BaseDao;

/**
 * BaseDaoImpl
 * 
 * @author simonall
 */
@SuppressWarnings("all")
public class BaseDaoImpl<T> extends AbstractBaseDao<T> implements BaseDao<T> {
	
	@Override
	public void save(T entity) {
		super.currentSession().save(entity);
	}

	@Override
	public void deleteById(String... id) {
		for (String i : id) {
			if (i != null && i.length() > BigInteger.ZERO.intValue()) {
				T record = super.currentSession().load(clazz, i);
				if (record != null) {
					super.currentSession().delete(record);
				}
			}
		}
	}

	@Override
	public void update(T entity) {
		super.currentSession().merge(entity);
	}

	@Override
	public T getById(Serializable id) {
		return (T) super.currentSession().get(clazz, id);
	}
}
